package cn.edu.gduf.luowowo.mgrsite.web.controller;

import cn.edu.gduf.luowowo.article.domain.Strategy;
import cn.edu.gduf.luowowo.article.query.StrategyQuery;
import cn.edu.gduf.luowowo.article.service.IDestinationService;
import cn.edu.gduf.luowowo.article.service.IStrategyService;
import cn.edu.gduf.luowowo.common.util.AjaxResult;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("strategy")
public class StrategyController {
    @Reference
    private IStrategyService strategyService;

    @Reference
    private IDestinationService destinationService;

    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo") StrategyQuery qo) {
        //pageInfo
        model.addAttribute("pageInfo", strategyService.query(qo));
        return "strategy/list";
    }

    @RequestMapping("/getDestByDeep")
    @ResponseBody
    public Object getDestByDeep(int deep) {
        return destinationService.getDestsByDeep(deep);
    }

    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate(Strategy strategy) {
        strategyService.saveOrUpdate(strategy);
        return AjaxResult.SUCCESS;
    }

}
